package com.tianitan.gen.common;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;


@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseResult<T> implements Serializable {

    private T data;
    private Integer code;
    private String message;

    public static <T> ResponseResult<T> success() {
        return success(null, ResponseCode.SUCCESS.getCode(), null);
    }

    public static <T> ResponseResult<T> success(String msg) {
        return success(null, ResponseCode.SUCCESS.getCode(), msg);
    }

    public static <T> ResponseResult<T> success(T data) {
        return success(data, ResponseCode.SUCCESS.getCode(), null);
    }

    public static <T> ResponseResult<T> success(String msg, T model) {
        return success(model, ResponseCode.SUCCESS.getCode(), msg);
    }

    public static <T> ResponseResult<T> success(T data, Integer code, String msg) {
        return new ResponseResult<T>(data, code, msg);
    }

    public static <T> ResponseResult<T> error() {
        return success(null, ResponseCode.ERROR.getCode(), null);
    }

    public static <T> ResponseResult<T> error(String msg) {
        return error(null, ResponseCode.ERROR.getCode(), msg);
    }

    public static <T> ResponseResult<T> error(T model, String msg) {
        return error(model, ResponseCode.ERROR.getCode(), msg);
    }

    public static <T> ResponseResult<T> error(T data, Integer code, String msg) {
        return new ResponseResult<T>(data, code, msg);
    }

}


